package com.example.hibernate.i.one2one_pk;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.Parameter;


@Entity
@Table(name = "T_ADDRESS")
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
public class Address {
	
	@Id
	@GeneratedValue(generator="myForeignGenerator")
	@org.hibernate.annotations.GenericGenerator(
			name="myForeignGenerator",
			strategy="foreign",
			parameters=@Parameter(name="property", value="user")
		)
	private Long id;
	private String street;
	private String zipcode;
	private String city;
	
	@OneToOne(mappedBy="address")
	private User user;
	
	public Long getId() {
		return id;
	}

	private void setId(Long id) {
		this.id = id;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	public String getZipcode() {
		return zipcode;
	}

	public void setZipcode(String zipcode) {
		this.zipcode = zipcode;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Override
	public String toString() {
		return "Address [id=" + id + ", street=" + street + ", zipcode=" + zipcode + ", city=" + city + "]";
	}
}
